%&context

\definecounter[sectionlvl]
\definedescription[descr][headstyle=bold,style=normal,align=normal,width=broad,margin=2em,distance=0em,hang=fit]

\def\doclassui#1{\color[darkgreen]{\ss\bf #1}}
\def\doclassname#1{{\bf #1}}
\def\doclassfig#1{\color[red]{\ss\bf #1}}
\def\doclassfn#1{{\tt #1}}
\def\doclassprop#1{\underbar{\tt\bf #1}}
\expandafter\def\csname doclassliteral number\endcsname#1{{\bf #1}}
\def\doclasskey#1{\strut\inframed[corner=0,frameradius=.8ex,frameoffset=-.1ex,strut=yes]{\ss\bf #1}}

\startxmlsetups xml:manual:root
    \xmlsetsetup{manual}{*}{-}
    \xmlsetsetup{manual}{document}{xml:manual:*}
	 \xmlsetsetup{manual}{docinfo|contact|copyright|field}{xml:manual:*}
	 \xmlsetsetup{manual}{topic}{xml:manual:*}
	 \xmlsetsetup{manual}{bullet_list|list_item}{xml:manual:*}
	 \xmlsetsetup{manual}{section|paragraph}{xml:manual:*}
	 \xmlsetsetup{manual}{definition_list|definition_list_item|definition}{xml:manual:*}
	 \xmlsetsetup{manual}{paragraph}{xml:manual:*}
    \xmlsetsetup{manual}{reference}{xml:manual:*}
	 \xmlsetsetup{manual}{literal|literal_block|inline}{xml:manual:*}
	 \xmlsetsetup{manual}{figure|legend}{xml:manual:*}
	 \xmlsetsetup{manual}{table|tgroup}{xml:manual:*}
	 \xmlsetsetup{manual}{thead|tbody}{xml:manual:*}
	 \xmlsetsetup{manual}{row|entry}{xml:manual:*}
\stopxmlsetups
\xmlregisterdocumentsetup{manual}{xml:manual:root}

\startxmlsetups xml:manual:document
\framed[align=center,width=\textwidth,frame=off]{%
\reference[\xmlattribute{#1}{}{ids}]{}{\tfd\bf\xmltext{#1}{/title}}\blank[2*big]
{\tfb\bf\xmltext{#1}{/subtitle}}\blank[2*big]
}%
	\xmlflush{#1}%
\stopxmlsetups

\startxmlsetups xml:manual:docinfo
\framed[width=\textwidth,align=center,frame=off]{%
\startembeddedxtable[frame=off]%
\startxrow
\startxcell\bf Author:\stopxcell
\startxcell \xmltext{#1}{/author}\stopxcell
\stopxrow
\startxrow
\startxcell\bf Contact:\stopxcell
\startxcell \xmlall{#1}{/contact}\stopxcell
\stopxrow
\startxrow
\startxcell\bf Date:\stopxcell
\startxcell \xmltext{#1}{/date}\stopxcell
\stopxrow
\xmlall{#1}{/field}%
\startxrow
\startxcell\bf Copyright:\stopxcell
\startxcell \xmlall{#1}{/copyright}\stopxcell
\stopxrow
\startxrow
\startxcell\bf Version:\stopxcell
\startxcell \xmltext{#1}{/version}\stopxcell
\stopxrow
\stopembeddedxtable
}%
\stopxmlsetups

\startxmlsetups xml:manual:reference
\edef\refuri{\xmlattribute{#1}{}{refuri}}
\mygoto{\myunderbar{\xmltext{#1}{}}}[
\ifx\refuri\empty
\xmlattribute{#1}{}{refid}\else
url(\refuri)\fi
]
\stopxmlsetups

\startxmlsetups xml:manual:field
\startxrow\startxcell\bf \xmltext{#1}{/field_name}:\stopxcell\startxcell
\xmlfirst{#1}{/field_body/paragraph}\stopxcell\stopxrow
\stopxmlsetups

\startxmlsetups xml:manual:topic
\reference[\xmlattribute{#1}{}{ids}]{}%
\edef\nodeclasses{\xmlattribute{#1}{}{classes}}%
\def\nodecontents{contents}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\nodeclasses\nodecontents
\startsubject[title={Table of Contents}]
\placecontent
\stopsubject
\else
\startsubject[title={\tfa\bf\xmltext{#1}{/title}}]%
\xmlall{#1}{/bullet_list}%
\stopsubject
\fi
\stopxmlsetups

\startxmlsetups xml:manual:bullet_list
\startitemize[inbetween={\blank[small]}]%
\xmlall{#1}{/list_item}%
\stopitemize
\stopxmlsetups
\startxmlsetups xml:manual:list_item
\startitem
\xmlflush{#1}%
\stopitem
\stopxmlsetups
\startxmlsetups xml:manual:definition_list
\xmlall{#1}{/definition_list_item}%
\stopxmlsetups
\startxmlsetups xml:manual:definition_list_item
\startdescr{\xmltext{#1}{/term}}%
\xmlall{#1}{/definition}%
\stopdescr
\stopxmlsetups
\startxmlsetups xml:manual:definition
\xmlflush{#1}%
\stopxmlsetups

\startxmlsetups xml:manual:inline
\ifcsname doclass\xmlattribute{#1}{}{classes}\endcsname
\csname doclass\xmlattribute{#1}{}{classes}\endcsname{\xmlflush{#1}}\else
\xmlflush{#1}\fi
\stopxmlsetups

\startxmlsetups xml:manual:literal
\inframed[frame=off,background=color,backgroundcolor=lightgray,backgroundoffset=-.2ex]{\tt
  \ctxlua{lxml.flushspacewise("\detokenize{#1}")}%
}%
\stopxmlsetups

\startxmlsetups xml:manual:literal_block
\blank[small]\startframedtext[width=\effectivehsize,frame=off,background=color,backgroundcolor=lightgray,style={\tt},align={flushleft,nothyphenated,verytolerant}]%
  \ctxlua{lxml.flushspacewise("\detokenize{#1}")}%
\stopframedtext\blank[small]%
\stopxmlsetups

\startxmlsetups xml:manual:figure
\placefigure[here]{{\em \xmltext{#1}{/caption}} \xmlall{#1}{/legend}}{\externalfigure[manual/\xmlattribute{#1}{/image}{uri}][width=.8\textwidth]}%
\stopxmlsetups
\startxmlsetups xml:manual:legend
\xmlflush{#1}%
\stopxmlsetups

\startxmlsetups xml:manual:definition_list
\xmlall{#1}{/definition_list_item}%
\stopxmlsetups
\startxmlsetups xml:manual:definition_list_item
\startdescr{\xmltext{#1}{/term}}%
\xmlall{#1}{/definition}%
\stopdescr
\stopxmlsetups
\startxmlsetups xml:manual:definition
\xmlflush{#1}%
\stopxmlsetups

\startxmlsetups xml:manual:section
\reference[\xmlattribute{#1}{}{ids}]{}%
\ifnum\rawcountervalue[sectionlvl]=0%
\strut
\startchapter[title={\xmltext{#1}{/title}}]%
\else \ifnum\rawcountervalue[sectionlvl]=1%
\startsection[title={\xmltext{#1}{/title}}]%
\else
\startsubsection[title={\xmltext{#1}{/title}}]%
\fi
\fi
\incrementcounter[sectionlvl]%
	\xmlflush{#1}%
\decrementcounter[sectionlvl]%
\ifnum\rawcountervalue[sectionlvl]=0%
\stopchapter
\else \ifnum\rawcountervalue[sectionlvl]=1%
\stopsection
\else
\stopsubsection
\fi
\fi
\stopxmlsetups

\startxmlsetups xml:manual:contact
    \xmlflush{#1}%
\stopxmlsetups
\startxmlsetups xml:manual:copyright
    \xmlflush{#1}%
\stopxmlsetups
\startxmlsetups xml:manual:paragraph
    \xmlflush{#1}\par
\stopxmlsetups

\startxmlsetups xml:manual:table
\framed[frame=off,width=\textwidth,align=center]{%
\xmlflush{#1}%
}%
\stopxmlsetups
\startxmlsetups xml:manual:tgroup
\startembeddedxtable[frame=off]%
\startxtablehead
\startxrow\startxcell[nx=2,background=color,backgroundcolor=black,frameoffset=0pt,offset=0pt,height=0pt,strut=no]\stopxcell\stopxrow
\bf \xmlall{#1}{/thead}%
\startxrow\startxcell[nx=2,background=color,backgroundcolor=black,frameoffset=0pt,offset=0pt,height=0pt,strut=no]\stopxcell\stopxrow
\stopxtablehead
\startxrowgroup
  \xmlall{#1}{/tbody}%
\stopxrowgroup
\startxrow\startxcell[nx=2,background=color,backgroundcolor=black,frameoffset=0pt,offset=0pt,height=0pt,strut=no]\stopxcell\stopxrow
\stopembeddedxtable
\stopxmlsetups
\startxmlsetups xml:manual:thead
\xmlall{#1}{/row}%
\stopxmlsetups
\startxmlsetups xml:manual:tbody
\xmlall{#1}{/row}%
\stopxmlsetups
\startxmlsetups xml:manual:row
\startxrow
\xmlall{#1}{/entry}%
\stopxrow
\stopxmlsetups
\startxmlsetups xml:manual:entry
\startxcell
\xmlflush{#1}%
\stopxcell
\stopxmlsetups

%\setupfloat[figure][indentnext=yes]%
%\setupinterlinespace[line=3.2ex]%
%\setupcaption[figure][number=no]%
\setupinteraction[state=start,
title={Fast Neurite Tracer},
subtitle={User Manual},
author={GOU Lingfeng (goulf@ion.ac.cn)},
keyword={}]%
\placebookmarks[chapter,section,subject][chapter,subject,force=yes]%
\setupinteractionscreen[option=bookmark]%
\setupcolor[state=start]%
\definereferenceformat[mygoto][color=blue,command=\goto]
\definebar[myunderbar][underbar][color=blue]


\starttext

    \xmlprocessfile{manual}{index.xml}{}

\stoptext

